import React from 'react';
import { PieChartOutlined } from '@ant-design/icons';
import { Navigate } from 'react-router-dom';

const Login = React.lazy(() => import('@/pages/login'));
const Layout = React.lazy(() => import('@/layout'));
const modules = import.meta.glob('./modules/**/*.tsx', {
  eager: true,
  import: 'default',
});
const routeModuleList: Route[] = [];

Object.keys(modules).forEach(key => {
  const mod = modules[key] || {};
  const modList = Array.isArray(mod) ? [...mod] : [mod];
  routeModuleList.push(...modList);
});
console.log(routeModuleList)
const routers: Route[] = [
  {
    path: '/sys',
    name: '首页',
    element: <Layout />,
    children: [...routeModuleList],
  },
  {
    path: '/',
    name: '',
    element: <Navigate to="/login"></Navigate>,
  },
  
  {
    name: '登录',
    path: 'login',
    element: <Login />,
    icon: <PieChartOutlined />,
  },
  {
    name: '404',
    path: '*',
    element: <Login />,
    icon: <PieChartOutlined />,
  },
];
console.log(routers);
export default routers;
